home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-28 | 2.1 KB | 88 lines | [TEXT/KAHL] |
- // Bolo code (C) Stuart Cheshire <cheshire@cs.stanford.edu> 1987-1995.
- // All rights reserved. This code is owned by Stuart Cheshire and is donated
- // free of charge for non-commercial use. You may not use this code in any
- // product sold for commercial profit, except shareware priced at $25 or less.
-
- #include "BrainFrame.h"
- #include "BF_ResourceIDs.h"
- #include "BF_Events.h"
- #include "BF_Main.h"
- #include "BF_Utils.h"
- #include "BF_Globals.h"
- #include "BF_Interface.h"
- #include "BF_IAC.h"
-
- local OSErr UpdateInfo(ConnectionInfo *conn)
- {
- OSErr retcode;
- static long last_call = 0;
- if (last_call == TickCount()) return(noErr);
- else last_call = TickCount();
-
- retcode = CallBolo(conn, BoloView);
- if (retcode) return(retcode);
-
- return(retcode);
- }
-
- export void BFInterfaceUpdateWindow(ConnectionInfo *conn)
- {
- SetPort(conn->win);
- MoveTo(20,40);
- DrawString("\pBrainFrame connected to Bolo player “");
- DrawString(conn->portinfo.name);
- DrawString("\p”");
- }
-
- local void CallBrain(ConnectionInfo *conn, u_short operation, u_short menu_item)
- {
- extern BoloBrain BrainMain;
- if (UpdateInfo(conn)) return;
- conn->info->operation = operation;
- conn->info->menu_item = menu_item;
- BrainMain(conn->info);
- }
-
- export void BFInterfaceIdle(ConnectionInfo *conn)
- {
- if (UpdateInfo(conn)) return;
- CallBrain(conn, BRAIN_THINK, 0);
- }
-
- export void BFInterfaceMenu(ConnectionInfo *conn, u_short menu, u_short item)
- {
- if (UpdateInfo(conn)) return;
- CallBrain(conn, menu, item);
- }
-
- export OSErr BFInterfaceOpen(ConnectionInfo *conn)
- {
- OSErr retcode = noErr;
- static const Rect r = { 40, 10, 120, 410 };
-
- conn->win = NewWindow(NULL,&r,"\pBrain",TRUE,zoomDocProc,(WindowPtr)-1,TRUE,0);
-
- // Comment out the following line if making a passive viewer that doesn't
- // override the tank controls, and Bolo will continue to operate the tank
- // under manual control.
- retcode = CallBolo(conn, BoloControl);
-
- CallBrain(conn, BRAIN_OPEN, 0);
- return(retcode);
- }
-
- export void BFInterfaceClose(ConnectionInfo *conn)
- {
- if (conn->win) DisposeWindow((GrafPtr)conn->win);
- CallBrain(conn, BRAIN_CLOSE, 0);
- }
-
- export OSErr BFInterfaceInit(void)
- {
- return(noErr);
- }
-
- export void BFInterfaceQuit(void)
- {
- }
-